package com.zhangtao.demo.config.redis.lettuce;

import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.RedisStringCommands;

import java.time.Duration;

public class LettucePool {
    public static void main(String[] args) {
        RedisClient client = RedisClient.create(RedisURI.builder()
                .withClientName("ztUtil")
                .withHost("10.135.80.34")
                .withPort(60965)
                .withPassword("Pass1234")
                .withDatabase(14)
                .withTimeout(Duration.ofMillis(30000))
                .build());
        StatefulRedisConnection<String, String> connection = client.connect();
        RedisStringCommands sync = connection.sync();
        sync.set("ZTTEST", System.currentTimeMillis() + "");
        Object value = sync.get("ZTTEST");
        System.out.println(value);
    }
}
